package com.hm.ipay.controller;

import com.hm.ipay.comm.aop.LoggerManage;
import com.hm.ipay.domain.result.ResponseData;
import com.hm.ipay.domain.result.ResponseDataList;
import com.hm.ipay.entity.GameInstance;
import com.hm.ipay.entity.GameParticipateIn;
import com.hm.ipay.service.GameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class GameController {

    @Autowired
    GameService gameService;

    @RequestMapping(value = "/game_instance_list", method = RequestMethod.POST)
    @LoggerManage(description = "游戏列表")
    public ResponseDataList gameInstanceList(Integer limit, Integer offset) {
        return gameService.gameInstanceList(limit, offset);
    }

    @RequestMapping(value = "/bg/add_game_instance", method = RequestMethod.POST)
    @LoggerManage(description = "添加游戏")
    public ResponseData addGameInstance(GameInstance instance) {
        return gameService.addGameInstance(instance);
    }

    @RequestMapping(value = "/get_game_instance", method = RequestMethod.POST)
    @LoggerManage(description = "获取游戏信息")
    public ResponseData getGameInstance(Long id) {
        return gameService.getGameInstance(id);
    }

    @RequestMapping(value = "/bg/set_game_instance_info", method = RequestMethod.POST)
    @LoggerManage(description = "设置游戏信息")
    public ResponseData setGameInstanceInfo(GameInstance instance) {
        return gameService.setGameInstanceInfo(instance);
    }

    @RequestMapping(value = "/game_bet_in", method = RequestMethod.POST)
    @LoggerManage(description = "游戏下注")
    public ResponseData gameBetIn(GameParticipateIn participate) {
        return gameService.gameBetIn(participate);
    }

    @RequestMapping(value = "/bg/game_part_in_list", method = RequestMethod.POST)
    @LoggerManage(description = "游戏参与列表")
    public ResponseDataList gamePartInList(Integer limit, Integer offset, Long gameId) {
        return gameService.gamePartInList(limit, offset, gameId);
    }

    @RequestMapping(value = "/bg/del_game", method = RequestMethod.POST)
    @LoggerManage(description = "删除游戏")
    public ResponseData delGameInstance(Long id) {
        return gameService.delGameInstance(id);
    }

    @RequestMapping(value = "/game_result", method = RequestMethod.POST)
    @LoggerManage(description = "游戏结果")
    public ResponseData gameResult(Long userId, Long gameId, Long partInId) {
        return gameService.gameResult(userId, gameId, partInId);
    }

    @RequestMapping(value = "/game_instance_list_new", method = RequestMethod.POST)
    @LoggerManage(description = "游戏列表")
    public ResponseDataList gameInstanceListNew(Integer limit, Integer offset, Long userId, int sortType, int sortDir) {
        return gameService.gameInstanceListNew(limit, offset, userId, sortType, sortDir);
    }

    @RequestMapping(value = "/user_part_in_list", method = RequestMethod.POST)
    @LoggerManage(description = "用户本次游戏参与列表")
    public ResponseDataList userPartInlist(Integer limit, Integer offset, Long userId, Long gameId) {
        return gameService.userPartInlist(limit, offset, userId, gameId);
    }

    @RequestMapping(value = "/game_instance_not_part", method = RequestMethod.POST)
    @LoggerManage(description = "游戏结果通知")
    public ResponseData getGameInstanceNotPart(Long userId) {
        return gameService.getGameInstanceNotPart(userId);
    }

    @RequestMapping(value = "/user_statistical", method = RequestMethod.POST)
    @LoggerManage(description = "用户本次游戏参与列表")
    public ResponseData userGameInfoStatistical(Long userId) {
        return gameService.userGameInfoStatistical(userId);
    }
}
